export default {
	//时间戳转换	
	timeStringTotime: function(timestamp) {
		var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
		var Y = date.getFullYear() + '-';
		var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
		var D = date.getDate() < 10 ? ('0' + date.getDate()) : (date.getDate());
		var h = date.getHours() + ':';
		var m = date.getMinutes() + ':';
		var s = date.getSeconds();
		return Y + M + D;
	},
	// day 传-1表始前一天，传1表始后一天
	// type 代表－或者+
	getNextDate: function(day, type) {
		// 获取当前的时间戳
		var curDate = new Date().getTime();
		// 把天数转换成毫秒
		var preDay = day * 24 * 60 * 60 * 1000
		var dateStr = ''
		if (type == '-') {
			// 通过时间戳转换成时间
			dateStr = this.timeStringTotime(curDate - preDay)
		} else {
			// 通过时间戳转换成时间
			dateStr = this.timeStringTotime(curDate + preDay)
		}
		return dateStr
	},

	//提示框
	showMessage: function(name) {
		uni.showToast({
			title: name,
			icon: "none",
			mask: true,
		});
		// #ifdef MP-WEIXIN
		wx.showToast({
			title: name,
			icon: "none",
			mask: true,
		});
		// #endif
	},
	//加载中
	hudLoading: function(name) {
		uni.showLoading({
			title: name,
			mask: true
		});
	},
	//取消
	hudHide: function() {
		uni.hideLoading();
	},
	//获取状态栏高度(电池栏)
	getNavtionBarHeight: function() {
		var height = uni.getSystemInfoSync().statusBarHeight;
		return height + 'px';
	},
	// 获取胶囊的高度
	getWXJNHeight: function() {
		let navbar = 10 // 自定义标题与胶囊对齐高度
		// #ifdef MP-WEIXIN
		let menuButtonInfo = wx.getMenuButtonBoundingClientRect()
		// console.log('输出看看bottom', menuButtonInfo.bottom)
		// console.log('输出看看height', menuButtonInfo.height)
		// console.log('输出看看width', menuButtonInfo.width)
		// console.log('输出看看top', menuButtonInfo.top)
		// console.log('输出看看right', menuButtonInfo.right)
		// console.log('输出看看left', menuButtonInfo.left)
		navbar = menuButtonInfo.top
		// #endif

		return navbar + 'px';
	},
	getWXJNHeightInt: function() {
		let navbar = 10 // 自定义标题与胶囊对齐高度
		// #ifdef MP-WEIXIN
		let menuButtonInfo = wx.getMenuButtonBoundingClientRect()
		// console.log('输出看看bottom', menuButtonInfo.bottom)
		// console.log('输出看看height', menuButtonInfo.height)
		// console.log('输出看看width', menuButtonInfo.width)
		// console.log('输出看看top', menuButtonInfo.top)
		// console.log('输出看看right', menuButtonInfo.right)
		// console.log('输出看看left', menuButtonInfo.left)
		navbar = menuButtonInfo.top
		// #endif

		return navbar;
	},
	// 获取导航栏总的高度
	getNavtionBarAllHeight: function() {
		let statusBar = 0 //状态栏高度
		let customBar = 0 // 状态栏高度 + 导航栏高度  
		let navbar = 0 // 自定义标题与胶囊对齐高度

		let e = uni.getSystemInfoSync();
		// // #ifdef MP
		// statusBar = e.statusBarHeight
		// customBar = e.statusBarHeight + 45
		// if (e.platform === 'android') {
		// 	this.$store.commit('SET_SYSTEM_IOSANDROID', false)
		// 	customBar = e.statusBarHeight + 50
		// }
		// // #endif

		// #ifdef MP-WEIXIN
		statusBar = e.statusBarHeight
		const custom = wx.getMenuButtonBoundingClientRect()
		customBar = custom.bottom + custom.top - e.statusBarHeight

		navbar = (custom.top - e.statusBarHeight) * 2 + custom.height
		// #endif

		// #ifdef H5
		statusBar = 0
		customBar = e.statusBarHeight + 45
		// #endif
		// console.log('111看看高的', navbar)
		// console.log('222看看高的', customBar)

		return customBar + 'px';
	},
	// 获取导航栏总的高度
	getNavtionBarAllHeightInt: function() {
		let statusBar = 0 //状态栏高度
		let customBar = 0 // 状态栏高度 + 导航栏高度  
		let navbar = 0 // 自定义标题与胶囊对齐高度

		let e = uni.getSystemInfoSync();
		// // #ifdef MP
		// statusBar = e.statusBarHeight
		// customBar = e.statusBarHeight + 45
		// if (e.platform === 'android') {
		// 	this.$store.commit('SET_SYSTEM_IOSANDROID', false)
		// 	customBar = e.statusBarHeight + 50
		// }
		// // #endif

		// #ifdef MP-WEIXIN
		statusBar = e.statusBarHeight
		const custom = wx.getMenuButtonBoundingClientRect()
		customBar = custom.bottom + custom.top - e.statusBarHeight

		navbar = (custom.top - e.statusBarHeight) * 2 + custom.height
		// #endif

		// #ifdef H5
		statusBar = 0
		customBar = e.statusBarHeight + 45
		// #endif
		// console.log('111看看高的', navbar)
		// console.log('222看看高的', customBar)

		return customBar;
	},

	//html标签格式化
	formatRichText: function(html) {
		let newContent = html.replace(/<img[^>]*>/gi, function(match, capture) {
			match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, '');
			match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, '');
			match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, '');
			return match;
		});
		newContent = newContent.replace(/style="[^"]+"/gi, function(match, capture) {
			match = match.replace(/width:[^;]+;/gi, 'max-width:100%;').replace(/width:[^;]+;/gi,
				'max-width:100%;');
			return match;
		});
		newContent = newContent.replace(/<br[^>]*\/>/gi, '');
		newContent = newContent.replace(/\<img/gi,
			'<img style="max-width:100%;height:auto;display:block;margin-top:0;margin-bottom:0;"');
		return newContent;
	},
	//校验手机格式
	checkMobile: function(mobile) {
		return RegExp(/^1[123456789]\d{9}$/).test(mobile);
	},

	//字符串转数组
	strSplitArr(str) {
		return str.split(','); // 以逗号,为拆分的字符串
	},


}